package com.campus.service;

import com.campus.entity.User;
import com.campus.mapper.UserMapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    @Transactional(readOnly = true)
    public User login(String loginName, String password) {
        return userMapper.login(loginName, password);
    }

    @Override
    @Transactional
    public void register(User user) {
        userMapper.insertUser(user);
    }

    @Override
    @Transactional(readOnly = true)
    public List<User> searchUserByNameOrId(String loginName, Integer id) {
        return userMapper.selectUserByNameOrId(loginName,id);
    }
}
